<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Document</title>
	</head>
	<style>
		#time {
			width: 200px;
			height: 100px;
			border-radius: 10px;
			background-color: pink;
			padding: 20px 0 0 30px;
		}
	</style>
	<body>
		<div id="time">
		</div>
		<script>
			//3. 使用js做一个电子表, 显示当前时间，格式为: yyyy-mm-dd hh:mm:ss, 并能够随时间跳动，可以参考js时间对象。
			function time() {
				let time = new Date();
				let years = time.getFullYear();
				let month = (time.getMonth()) + 1;
				let date = time.getDate();
				let hours = time.getHours();
				let minutes = time.getMinutes();
				let second = time.getSeconds();
				if (month < 10) {
					month = "0" + month;
				}
				if (date < 10) {
					date = "0" + date;
				}
				if (hours < 10) {
					hours = "0" + hours;
				}
				if (minutes < 10) {
					minutes = "0" + minutes;
				}
				if (second < 10) {
					second = "0" + second;
				}
				document.getElementById('time').innerHTML = years + "-" + month + "-" + date + '  ' + hours + ":" + minutes + ":" +
					second;
			}
			setInterval("time()", 1000);
		</script>

	</body>
</html>
